home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: artemis.sto.fdata.se!news
- From: Niklas Mellin <niklas.mellin@sto.fdata.se>
- Subject: Re: Operators <<= and >>=
- Sender: news@artemis.sto.fdata.se (UseNet NetNews)
- Message-ID: <31638745.65B8@sto.fdata.se>
- Date: Thu, 4 Apr 1996 08:24:37 GMT
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
- References: <4iva5m$4q5@access4.digex.net> <Pine.OSF.3.91.960403110722.17337E-100000@bud.cc.swin.edu.au>
- Mime-Version: 1.0
- X-Mailer: Mozilla 2.0 (WinNT; I)
- Organization: WM-data F÷rsvarsdata AB, Sweden
-
- John Joseph Newbigin wrote:
- >
- > On 22 Mar 1996, Mr. Blue wrote:
- >
- > >
- > > When / why would one overload the operators <<= and >>= ?
- >
- > Much greater(or less) that or equal?
-
- operator <<= means left shift of left operand for built in
- types, and operator >>= means right shift
-
- int foo = 3; // 00000011
- //shift bits in foo 2 places to the left
- foo <<= 2; // 00001100
-
- I can imagine they can be useful when you have a class representing
- some kind of bit pattern, but I have never overloaded those operators
- in production code.
-
- Overloading operators is an important feature in C++, if used correctly
- it can make your programs much more readable. But used correctly also
- means that you should not overload every possible operator just because
- the language lets you.
-
- ---
- Niklas Mellin
-